<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">

    </ma-crud>
    <Event v-model="visible.event" />
  </div>
</template>
<script setup>
import { ref, reactive,provide } from 'vue'
import feeType from '@/api/finance/feeType'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import Event from './event.vue'
import * as common from '@/utils/common'

const crudRef = ref()
const record = ref({})

const visible = ref({
  event: false,
})

const options = reactive({
  id: 'fee_type',
  pageLayout: 'fixed',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  // pageLayout: 'normal',
  formOption: {
    viewType: 'drawer',
    width: "80%"
  },
  api: feeType.getList,
  see:{
    show: true,
    text:'事件',
    action:(rec)=>{
      record.value = rec
      visible.value.event = true
    }
  },
  add: {
    show: true,
    api: feeType.save,
    auth: ['finance:feeType:save']
  },
  edit: {
    show: true,
    api: feeType.update,
    auth: ['finance:feeType:update']
  },
  delete: {
    show: true,
    api: feeType.deletes,
    auth: ['finance:feeType:delete']
  }
})

const columns = reactive([
  {
    title: "主键",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入主键"
    }
  },
  {
    title: "代码",
    dataIndex: "fee_code",
    formType: "input",
  },
  {
    title: "名称",
    dataIndex: "fee_name",
    formType: "input",
  },
  {
    title: "类型",
    dataIndex: "cate",
    formType: "select",
    multiple:true,
    dict: {
      name: 'FeeType',
      props: {
        label: "title",
        value: "key"
      },
      translation: true,
      },
    // commonRules: {
    //   required: true,
    //   message: "请输入类型"
    // },
    dict: {
      name: "FeeType",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
    }
  },
  {
    title: "是否可见",
    dataIndex: "is_visible",
    formType: "radio",
    addDefaultValue:1,
    checkedValue: 1,
    dict:{
      data: [
        {
          label: "是",
          value: 1
        },
        {
          label: "否",
          value: 0
        }
      ],
      translation: true
    },
    uncheckedValue: 2
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,

    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,

    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
provide('crudRef', crudRef)
provide('record', record)
</script>
<script> export default { name: 'finance:feeType' } </script>